/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.images;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;

/**
 * <p>Project: jse2204 - Font1
 * <p>Powered by webrx On 2022-09-26 14:06:06
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Font1 {
    public static void main(String[] args) throws Exception{
        int width = 500;
        int height = 500;
        BufferedImage img = new BufferedImage(width,height,1);
        Graphics2D g = img.createGraphics();
        //设置线条和文件的，抗锯齿（平滑）
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);

        Font[] fs = Font.createFonts(new File("fonts/zh164hfyh.ttf"));
        Font font = fs[0].deriveFont(Font.BOLD,72);
        g.setFont(font);

        g.setColor(Color.RED);

        //BasicStroke stroke = new BasicStroke(13);
        //g.setStroke(stroke);


        g.drawString("hello 中文",5,30);


        //g.drawLine(250,0,250,500);


        g.dispose();
        ImageIO.write(img,"jpg",new File("m1.jpg"));

        Runtime.getRuntime().exec("cmd /k start m1.jpg");

    }
}
